import request from '../../utils/request.js'


const state ={
	 indexData:{},
	 homeNav:[]
}

const mutations ={
	SET_INDEXDATA(state,{data,nav}){
		state.indexData = data
		state.homeNav = nav.homeNav
	},
	
}

const actions ={
	async getIndexData({commit}){
		 const result = await request('/getHomeData')
		 if(result.code === '000000'){
			 // console.log(result.data,result.nav);
			commit('SET_INDEXDATA',result)
			 
		 }
	 }
}

const getters ={
	//轮播图
	bannerUrls(){
		return  state.indexData?.bannerUrls || []
	},
	//热销车型
	hotProducts(){
		return  state.indexData?.hotProducts || []
	},
	//车生活
	topics(){
		 return state.indexData?.topics || []
	}
	
	
}

export default {
	 state,
	 mutations,
	 actions,
	 getters
}
